package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.ChanPinFenLei;
import com.ysd.util.DBManager;

public class ChanPinFenLeiDaoImpl {
	public List<ChanPinFenLei> getChanPinFenLei(){
		List<ChanPinFenLei> chanPinFenLeiList = new ArrayList<ChanPinFenLei>();
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from chanPinFenLei");
			while(rs.next()) {
				int chanPinId = rs.getInt("chanPinId");
				String chanPinName = rs.getString("chanPinName");
				ChanPinFenLei chanPinFenLei =new ChanPinFenLei(chanPinId, chanPinName);
				chanPinFenLeiList.add(chanPinFenLei);
			}
			return chanPinFenLeiList;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
